package qmm.demo;

import java.beans.PropertyVetoException;
import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.mysql.jdbc.Connection;


@WebServlet("/c3p0Test")
public class c3p0Test{
	public static void main(String[] args){
		ComboPooledDataSource cpds=new ComboPooledDataSource();
		try{
			cpds.setDriverClass("com.mysql.jdbc.Driver");
			cpds.setJdbcUrl("jdbc:mysql://localhost:3306/test");
			cpds.setUser("root");
			cpds.setPassword("admin");
			cpds.setInitialPoolSize(8);
			cpds.setMaxPoolSize(20);
			DataSource ds=cpds;
			Connection conn=(Connection) ds.getConnection();
			System.out.print(conn);
		}catch(PropertyVetoException e){
			e.printStackTrace();
		}catch(SQLException e){
			e.printStackTrace();
		}
		
	}

    public c3p0Test() {
        super();
        // TODO Auto-generated constructor stub
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
